<template>
    <div class="service-details">
        <div class="breadcrumb">
            <RouterLink class="plain-link breadcrumb-link" :to="{ name: '/home/service-list' }">服务列表</RouterLink>
            / 详情页面
        </div>
        <div class="service-content">
            <div class="service-preview">
                <ServiceDetailsImages />
            </div>
            <div class="detail-section">
                <h2 class="service-title">{{ serviceDetails.serviceName }}</h2>
                <div>
                    <ServiceSpecSelect :specs="serviceDetails.specs" :skus="serviceDetails.skus" />
                </div>
                <div class="divider"></div>
                <div>
                    <h3 class="description-title">商品描述</h3>
                    <p>{{ serviceDetails.serviceDesc }}</p>
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { getServiceById } from '@/api/api.query.util';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import ServiceDetailsImages from './Components/ServiceDetailsImages.vue';
import ServiceSpecSelect from './Components/ServiceSpecSelect.vue';

const route = useRoute();
const id = ref('');
const serviceDetails = ref({});

if (typeof route.params.id !== 'string') {
    const [value] = route.params.id;
    id.value = value;
} else {
    id.value = route.params.id;
}

// 获取服务详情
getServiceDetails();

async function getServiceDetails() {
    const result = await getServiceById({
        method: 'POST',
        data: {
            serviceId: id.value,
        },
    });
    serviceDetails.value = result.result;
}
</script>

<style lang="scss" scoped>
.service-details {
    flex-grow: 1;
    padding: 15px 95px 110px 30px;
    background-color: var(--section-color);
    border-radius: var(--border-radius);
}

.breadcrumb,
.breadcrumb-link {
    color: var(--font-color-slight);
}

.service-content {
    display: flex;
    margin-top: 40px;
    gap: 64px;
}

.service-preview {
    width: 450px;
    flex-shrink: 0;
}

.detail-section {
    flex-grow: 1;
}

.service-title {
    margin-top: -5px;
    font-size: var(--font-size-extra);
    line-height: 28px;
    color: var(--font-color);
    margin-bottom: 30px;
    font-weight: 600;
}

.divider {
    width: 100%;
    height: 1px;
    background-color: var(--divider-color);
    margin: 32px 0;
}

.description-title {
    font-size: var(--font-size-extra);
    margin-bottom: 22px;
}
</style>
